package fitness;

import model.Input;

public class TicTacToeResult extends FitnessResult {

	public static double bonus = 1.0;
	Input[] inputs;
	boolean correct;
	double[][] timeSeries;
	int dim;
	int width;
	int height;
	
	public TicTacToeResult(Input[] inputs, boolean correct, double[][] timeSeries, int dim, int width, int height){
		this.inputs = inputs;
		this.correct = correct;
		this.timeSeries = timeSeries;
		this.dim = dim;
		this.width = width;
		this.height = height;
	}
	
	@Override
	public Double[] getDecomposition() {
		Double[] decomposition = new Double[1+width*height]; // scores for being correct and playing up to width*height steps
		for(int i=0; i< decomposition.length; i++){
			decomposition[i] = 0.0;
		}
		decomposition[1] = inputs[0].timeStep==-1?0:bonus;
		for(int i=1; i< inputs.length; i++){
			decomposition[i+1] = inputs[i].timeStep==-1?0:bonus* (double) i;
		}
		
		return decomposition;
	}

	@Override
	public double finalResult() {
		Double[] dec = getDecomposition();
		double res = 0;
		for(int i = 0; i< dec.length; i++){
			res += dec[i];
		}
		return res;
	}

	@Override
	public boolean goodSolution() {
		// TODO Auto-generated method stub
		return false;
	}

}
